<template>
  <div class="hot">
    <div class="container">
      <div class="hot-title">
        <span class="title">热点资讯</span>
        <el-link :underline="false" class="link more" @click="GoInformationList(0)">查看更多<i class="el-icon-arrow-right" /></el-link>
      </div>
    </div>
    <div class="container hot-content">
      <ul class="information">
        <li v-for="item in listNewsData" :key="item.id" class="hot-information" @click="GoInformationDetail(item.id,3)">
          <div class="image">
            <img class="hot-img" :src="item.coverImage" alt="">
          </div>
          <div class="title">
            <span class="text-line-1">{{ item.newsIntroduct }}</span>
            <div class="title-down">
              <span>{{ parseTime(item.createTime,'{y}-{m}-{d}') }}</span>
              <span>【查看全文】</span>
            </div>
          </div>
        </li>
      </ul>
    </div>
    <div class="container hot-special">
      <div class="special-left">
        <ul class="special-content">
          <li class="special-text"><span class="size">国家政策</span><el-link :underline="false" class="link" @click="GoInformationList(1)">查看更多<i class="el-icon-arrow-right" /></el-link></li>
          <li v-for="item in policyNewsData" :key="item.id" class="special-text">
            <el-link :underline="false" class="link">
              <div class="text-content text-line-1" @click="GoInformationDetail(item.id,2)">
                <span>{{ item.newsIntroduct }}</span>
              </div>
            </el-link>
            <span>{{ parseTime(item.createTime,'{y}-{m}-{d}') }}</span>
          </li>
        </ul>
      </div>
      <div class="special-left">
        <ul class="special-content">
          <li class="special-text"><span class="size">行业资讯</span><el-link :underline="false" class="link" @click="GoInformationList(2)">查看更多<i class="el-icon-arrow-right" /></el-link></li>
          <li v-for="item in industryNewsData" :key="item.id" class="special-text">
            <el-link :underline="false" class="link">
              <div class="text-content text-line-1" @click="GoInformationDetail(item.id,1)">
                <span>{{ item.newsIntroduct }}</span>
              </div>
            </el-link>
            <span>{{ parseTime(item.createTime,'{y}-{m}-{d}') }}</span>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>
<script>
import { listNews } from '@/api/hot-consulting'
export default {
  name: 'Hot',
  data() {
    return {
      listNewsData: [],
      industryNewsData: [],
      policyNewsData: []
    }
  },
  created() {
    this.listNews()
    this.industryNews()
    this.policyNews()
  },
  methods: {
    // 获取热点咨询列表
    listNews() {
      listNews(1, 4, 3).then(res => {
        console.log(res)
        this.listNewsData = res.data.records
        const d = JSON.stringify(res.data.records)
        localStorage.setItem('listNewsData', d)
      })
    },
    // 获取业内活动列表
    industryNews() {
      listNews(1, 6, 1).then(res => {
        // console.log('获取业内活动列表', res)
        this.industryNewsData = res.data.records
        const d = JSON.stringify(res.data.records)
        localStorage.setItem('industryNewsData', d)
      })
    },
    // 获取国家政策列表
    policyNews() {
      listNews(1, 6, 2).then(res => {
        // console.log('获取国家政策列表', res)
        this.policyNewsData = res.data.records
        const d = JSON.stringify(res.data.records)
        localStorage.setItem('policyNewsData', d)
      })
    },
    GoInformationList(type) {
      this.$router.push({
        path: '/information-list',
        query: {
          type
        }
      })
    },
    GoInformationDetail(id, type) {
      this.$router.push({
        path: '/information-detail',
        query: {
          id,
          type
        }
      })
    }
  }
}
</script>
<style scoped lang="scss">
@import "@/assets/style/common-color.scss";
    .hot{
        background: #F5F5F5;
        .hot-title{
          font-size:16px;
          padding: 17px 20px 20px 20px;
          display: flex;
          justify-content: space-between;
          .title{
            color: #3D3D3D;
            font-size: 16px;
            font-weight: bold;
          }
          .more{
            font-size: 14px;
          }
        }
        .hot-content{
            .information{
                display:flex;
                .hot-information{
                    width:285px;
                    height:257px;
                    background:#FFFFFF;
                    margin-right:20px;
                    cursor:pointer;
                    .image{
                        width:265px;
                        height:164px;
                        .hot-img{
                            width:265px;
                            height:164px;
                            object-fit: cover;
                            margin:10px 10px 0 10px;
                        }
                    }
                    .title{
                        margin-top: 15px;
                        margin-left: 10px;
                        .title-down{
                            display: flex;
                            justify-content: space-between;
                            margin-top: 14px;
                        }
                    }
                }
            }
        }
        .hot-special{
            display:flex;
            justify-content: space-between;
            .special-left{
                width:590px;
                // height:246px;
                background:#FFFFFF;
                margin-top:20px;
                font-size:12px;
                margin-bottom: 60px;
                .special-content{
                    margin:16px 17px 0px 20px;
                    .special-text{
                        display: flex;
                        justify-content: space-between;
                        margin-bottom:15px;
                      .text-content{
                        width: 380px;
                      }
                      .size{
                        color: #3D3D3D;
                        font-size: 16px;
                        font-weight: bold;
                      }
                    }
                }
            }
        }
      .el-link {
        font-weight: 500;
        font-size: 12px;
      }
    }
</style>
